<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: lijincheng
  Date: 2021/5/30
  Time: 1:30 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>我的浏览记录</title>
    <!-- CUSTOM STYLE -->
    <link href="/css/style.css" rel="stylesheet">
    <link href="/css/car/style.css" rel="stylesheet">
    <!-- THEME TYPO -->
    <link href="/css/themetypo.css" rel="stylesheet">
    <!-- BOOTSTRAP -->
    <link href="/css/bootstrap.css" rel="stylesheet">
    <!-- COLOR FILE -->
    <link href="/css/color.css" rel="stylesheet">
    <!-- FONT AWESOME -->
    <link href="/css/font-awesome.min.css" rel="stylesheet">
    <!-- BX SLIDER -->
    <link href="/css/jquery.bxslider.css" rel="stylesheet">

    <link href="/css/bootstrap-slider.css" rel="stylesheet">

    <link href="/css/widget.css" rel="stylesheet">

    <link href="/css/shortcode.css" rel="stylesheet">
    <!-- responsive -->
    <link href="/css/responsive.css" rel="stylesheet">
    <!-- Component -->
    <link href="/js/dl-menu/component.css" rel="stylesheet">
    <style>
        input{
            width: 20px;
        }
    </style>
</head>
<body>
<div id="loader-wrapper">
    <div id="loader"></div>
    <div class="loader-section section-left"></div>
    <div class="loader-section section-right"></div>

</div>
<!--WRAPPER START-->
<div class="wrapper kode-header-class-3">
    <!--HEADER START-->
    <header class="header-3">
        <div class="container">
            <div class="logo-container">
                <div class="row">
                    <div class="col-md-3">
                        <!--LOGO START-->
                        <div class="logo">
                            <a href="#"><img src="/images/logo-2.png" alt=""></a>
                        </div>
                        <!--LOGO END-->
                    </div>
                    <div class="col-md-9">
                        <div class="top-strip">
                            <div class="pull-left">
                                <p>Welcome to Library theme</p>
                            </div>
                            <div class="social-icon">
                                <c:choose>
                                    <c:when test="${sessionScope.user == null}">
                                        <li><a id="onload-login" href="/login/index" class="pull-left">亲，请登录</a>
                                            <a href="${pageContext.request.contextPath}/register/index"
                                               class="pull-left">免费注册</a></li>
                                    </c:when>
                                    <c:otherwise>
                                        <li><a href="#" class="pull-left">欢迎 ${sessionScope.user.getUName()}</a></li>
                                    </c:otherwise>
                                </c:choose>
                            </div>
                        </div>
                        <div class="kode-navigation">
                            <ul>
                                <li><a href="/">主页</a>
                                    <ul>
                                        <li><a href="/">主页</a></li>
                                    </ul>
                                </li>
                                <c:choose>
                                    <c:when test="${sessionScope.user != null}">
                                        <li><a href="">图书管理</a>
                                            <ul>
                                                <li><a href="/ubook/post/index">发布图书</a></li>
                                                <li><a href="/ubook/myBooks">我的发布记录</a></li>
                                            </ul>
                                        </li>
                                        <li><a href="">购物车</a>
                                            <ul>
                                                <li><a href="/shop/car/index">我的购物车</a></li>
                                            </ul>
                                        </li>
                                        <li><a href="">订单管理</a>
                                            <ul>
                                                <li><a href="/order/index">所有订单</a></li>
                                                <li><a href="">待收货</a></li>
                                                <li><a href="">已完成</a></li>
                                            </ul>
                                        </li>
                                        <li><a href="">个人中心</a>
                                            <ul>
                                                <li><a href="/user/userInfo/#caa">个人信息</a></li>
                                                <li><a href="/browse/history/list">我的浏览记录</a></li>
                                                <li><a href="/user/loginout">退出登陆</a></li>
                                            </ul>
                                        </li>
                                    </c:when>
                                </c:choose>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header>
    <!--HEADER END-->
    <!--BANNER START-->
    <div class="kode-inner-banner" style="background-image: url('/images/style2-blog3.png');">
        <div class="kode-page-heading">
            <h2>浏览历史记录</h2>
            <ol class="breadcrumb">
                <li><a href="#">主页</a></li>
                <li class="active">我的浏览记录</li>
            </ol>
        </div>
    </div>
    <!--BANNER END-->
    <!--CONTENT START-->
    <div class="kode-content">
        <!--TOP AUTHERS START-->
        <div class="container" style="width: 90%">
            <div class="shopping-car-container">
                <div class="car-headers-menu">
                    <div class="row">
                        <div class="col-md-1 car-menu">
                            <label><input type="checkbox" id="check-goods-all"/></label>
                        </div>
                        <div class="col-md-2 car-menu">商品信息</div>
                        <div class="col-md-3 car-menu">商品参数</div>
                        <div class="col-md-1 car-menu">单价</div>
                        <div class="col-md-2 car-menu">时间</div>
                        <div class="col-md-1 car-menu">状态</div>
                        <div class="col-md-2 car-menu">操作</div>
                    </div>
                </div>
                <div class="goods-content">
                    <c:forEach items="${list}" var="vo">
                        <div class="goods-item">
                            <div class="panel panel-default">
                                <div class="panel-body">
                                    <div class="col-md-1 car-goods-info"><label>
                                        <input type="checkbox"
                                               class="goods-list-item" value="${vo.id}"></label>
                                    </div>
                                    <div class="col-md-2 car-goods-info goods-image-column">
                                        <a href="/ubook/detail/${vo.bookId}">
                                            <img class="goods-image"
                                                 src="/upload/${vo.imgurl}"
                                                 style="width: 100px; height: 100px;" alt="${vo.bookTitle}"/></a></div>
                                    <div class="col-md-3 car-goods-info goods-params"><a href="/ubook/detail/${vo.bookId}">${vo.bookTitle}</a></div>
                                    <div class="col-md-1 car-goods-info goods-price"><span>￥</span><span
                                            class="single-price">${vo.bookPrice}</span>
                                    </div>
                                    <div class="col-md-2 car-goods-info goods-counts">
                                        <div class="input-group">
                                            <span>${vo.createTime}</span>
                                        </div>
                                    </div>
                                    <div class="col-md-1 car-goods-info goods-money-count"><span>${vo.flagValue}</span></div>
                                    <div class="col-md-2 car-goods-info goods-operate text-center">
                                        <button type="button" class="btn btn-danger item-delete" onclick="deleteHistory('${vo.id}')">删除</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </c:forEach>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body bottom-menu-include">
                        <div class="col-md-1 check-all-bottom bottom-menu">
                            <label>
                                <input type="checkbox" id="checked-all-bottom" />
                            </label>
                        </div>
                        <div class="col-sm-8"></div>
                        <div class="col-md-1 bottom-menu">
                            <button type="button" class="btn btn-danger item-delete" onclick="batchDelete()">删除</button>
                        </div>
                        <div class="col-md-2 bottom-menu">
                            <button type="button" class="btn btn-danger item-delete" onclick="checkedAll()">清除浏览记录</button>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <!--TOP AUTHERS END-->
    </div>
    <!--CONTENT END-->
    <div class="copyrights">
        <div class="container">
            <p>Copyrights © 2015-16 KodeForest. All rights reserved</p>
            <div class="cards"><img src="/images/cards.png" alt=""></div>
        </div>
    </div>
</div>

<!--WRAPPER END-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/js/bootstrap.min.js"></script>
<script src="/js/dl-menu/modernizr.custom.js"></script>
<script src="/js/dl-menu/jquery.dlmenu.js"></script>
<script src="/js/jquery.bxslider.min.js"></script>
<script src="/js/bootstrap-slider.js"></script>
<script src="/js/waypoints.min.js"></script>
<script src="/js/jquery.counterup.min.js"></script>
<script src="/js/functions.js"></script>
<script src="/js/car/script.js"></script>
</body>
<script>
    function deleteHistory(id){
        $.ajax({
            type:"POST",
            data:{"id":id},
            url:"/browse/history/delete",
            success:function (data){
                window.location.reload();
            }
        });
    }
    function clearHistory(){
        $.ajax({
            type:"POST",
            url:"/browse/history/clearAll",
            success:function (data){
                window.location.reload();
            }
        });
    }
    function batchDelete(){
        var ids = "";
        $.each($('input:checkbox:checked'), function () {
            var dcId = $(this).val();
            console.log("dcId:" + dcId);
            if (dcId !== "on") {
                ids += dcId + ",";
            }
        });
        $.ajax({
            type:"POST",
            data:{"ids":ids},
            url:"/browse/history/batchDelete",
            success:function (data){
                if (data.code === 1){
                    alert("请选择至少一条记录");
                    return;
                }
                window.location.reload();
            }
        });
    }
</script>
</html>
